package com.gluck.cases.common.utils.utils.jackson;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import com.gluck.cases.common.utils.utils.TimeUtils;

import java.io.IOException;
import java.time.LocalDate;

/**
 * LocalDate序列化
 * @author sunpeng
 */
public class LocalDateSerializer extends StdSerializer<LocalDate> {

    private static final long serialVersionUID = 1622299786924706291L;

    public LocalDateSerializer() {
        this(null);
    }

    public LocalDateSerializer(Class<LocalDate> t) {
        super(t);
    }

    public void serialize(LocalDate value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
        jgen.writeNumber(TimeUtils.getTimestamp(value));
    }
}